Component({
    data: {
        show: false,
        goodsInfo: {},
        number: 0
    },
    methods: {
        switch (parameter) {
            if (parameter != null && parameter != undefined) {
                this.setData({
                    goodsInfo: parameter,
                    number:parameter.number
                });
            };
            this.setData({
                show: !this.data.show
            });
        },
        reduceOperation() {
            this.setData({
                number: this.data.number - 1
            });
        },
        addOperation() {
            this.setData({
                number: this.data.number + 1
            });
        },
        saveAndClose() {
            let result = {
                id: this.data.goodsInfo.id,
                name: this.data.goodsInfo.name,
                real:this.data.goodsInfo.real,
                imageUrl:this.data.goodsInfo.imageUrl,
                number: this.data.number,
                typeId:this.data.goodsInfo.typeId,
                check:this.data.goodsInfo.check
            };
            this.triggerEvent("closePopup", result);    //触发一个事件，事件的名字是：closePopup。
            this.switch();
        },
        radioChange(event){
            let temp = this.data.goodsInfo;
            temp.check.forEach(item=>{
                if(item.value==event.detail.value){
                    item.checked = true;
                }else{
                    item.checked = false;
                }
            });
        }
    }
});